package com.bluefish.bltuan.module.mail;

import static com.bluefish.bltuan.module.mail.EmailVariable.*;

public enum EmailPurpose {

	REGISTER("register",
			new EmailVariable[]{USERNAME,PASSWORD}),
	
	FIND_PASSWORD("find-password",
			new EmailVariable[]{USERNAME,NEW_PASSWORD}),
	
	SUBSCRIBER("subscribe",
			new EmailVariable[]{USERNAME,SUBSCRIBER_TITLE,SUBSCRIBER_CONTENT}),
	
	SUBSCRIBER_NOT_YET("subscriber-not-yet",
			new EmailVariable[]{USERNAME});
	
	private String key;
	
	private EmailVariable[] variables;
	
	private EmailPurpose(String key, EmailVariable[] variables){
		this.key = key;
		this.variables = variables;
	}
	
	@Override
	public String toString() {
		return this.key;
	}
	
	public static EmailPurpose valueOfString(String str){
		String value = str.replaceAll("-", "_").toUpperCase();
		return valueOf(value);
	}
	
	public String getKey() {
		return key;
	}
	
	public EmailVariable[] getVariables() {
		return variables;
	}
}
